package sdk.pay.utils.dynamic;

import android.content.Context;
import android.content.IntentFilter;
import android.net.ConnectivityManager;

import sdk.pay.receiver.PayNetworkReceiver;
import sdk.pay.utils.PayNetUtil;

/**
 * Created by Joe on 2017/08/05 11:30.
 */

public class PayDynamicUtil {
    private static class InstanceHolder {
        static PayDynamicUtil handler = new PayDynamicUtil();
    }

    public static PayDynamicUtil getInstance() {
        return InstanceHolder.handler;
    }

    public void init(Context context) {
        if (PayNetUtil.isNetworkAvailable()) {
            PayDownloadUtil.getInstance().download(context);
        } else {
            PayDownloadUtil.getInstance().initData(context);
        }
        IntentFilter intentFilter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
        PayNetworkReceiver payNetworkReceiver = new PayNetworkReceiver();
        context.registerReceiver(payNetworkReceiver, intentFilter);
    }

}
